import sys
import time
from random import randint
def gen_ip():
    ip = str(randint(0,255))
    ip += '.'
    ip += str(randint(0,255))
    ip += '.'
    ip += str(randint(0,255))
    ip += '.'
    ip += str(randint(0,255))
    ip += '.'
    ip += str(randint(0,255))
    return ip
if __name__ == '__main__':
    userip = '202.173.9.227'
    domain = ['www.baidu.com', 'www.qq.com.', 'www.abc.com']
    fp = open('query.log', 'a')
    for i in xrange(int(sys.argv[1])):
        record = userip
        record += '|'
        record += domain[randint(0, len(domain)-1)]
        record += '|'
        record += time.strftime("%Y%m%d%H%M%S")
        record += '|'
        record += gen_ip()
        record += '|'
        record += str(randint(0, 5))
        record += '|'
        record += str(randint(0, 1000))
        fp.write(record + '\n')
        time.sleep(0.01)

    fp.close()
